package com.frank.yinyuetai.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.frank.yinyuetai.Adapter.MvViewPagerAdapter;
import com.frank.yinyuetai.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/8/17 0017.
 */
public class MvFragment extends Fragment {
    @Bind(R.id.tabLayout)
    TabLayout tabLayout;
    @Bind(R.id.mv_pager)
    ViewPager mvPager;
    private MvViewPagerAdapter pagerAdapter;
    private String[] titles = new String[]{"首播", "韩国", "欧美", "日本", "内地", "港台", "热推"};

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.second_fragment_layout, null);
        ButterKnife.bind(this, view);
        //fragment中嵌套fragment，一定要写getChildFragmentManager()
        pagerAdapter = new MvViewPagerAdapter(getChildFragmentManager(), titles);
        mvPager.setAdapter(pagerAdapter);
        tabLayout.setupWithViewPager(mvPager);
        return view;
    }

}
